<template>
  <div @click="loadMore" id="LoadMore">
    <ul>
      <li v-if="noMore">
        {{$t('mall.loadMore')}}
      </li>
      <li v-else>
        {{$t('mall.noMore')}}
      </li>
    </ul>
  </div>
</template>

<script>
    export default {
        name: "newsLoadMore",
      methods:{
        loadMore(){
          if(this.noMore){
            this.getNews();
          }
        },
        getNews(){
          //获取分类下的产品
          this.$store.dispatch('toChangeLoadIngVisible',true);
          let _this=this;
          this.nowPages=this.nowPages+1;
          this.axios.get(domain.url+'news/api/get_news',{
            params:{
              language:_this.lang,
              page:_this.nowPages,
            }
          })
            .then(function (response) {
              let data=response.data;
              _this.$store.dispatch('toAddCompanyNewsList',data.list.data);     //将获取到的新数据与旧数据相连接
              if(data.list.data.length<3){
                _this.noMore=false;
              }
              _this.$store.dispatch('toChangeLoadIngVisible',false);
            })
            .catch(function (error) {
              console.log(error);
            });
        }
      },
      computed: {
        lang:{
          get(){
            let storageData = window.sessionStorage.getItem('lang');
            if(this.$store.state.lang!==storageData&&storageData!=='null'){
              this.$store.dispatch('toChangeLang', storageData);    //同步操作
            }
            return this.$store.getters.getLang;
          },
          set(){}
        },
      },
      data(){
        return{
          nowPages:1,
          noMore:true,
        }
      },
      props:{}
    }
</script>

<style scoped>
  #LoadMore{
    color:#999999;
    background: #f5f5f5;
    height:50px;
    width:100%;
    line-height: 50px;
    font-size:13px;
  }
</style>
